
#include <LengthUnit.h>

LengthUnit::LengthUnit(int factor, const char* name):Unit(factor, name)
{
}

const LengthUnit* LengthUnit::getFeet()
{
    static const LengthUnit feet(FEET_TO_BASEUNIT, "FEET");
    return &feet;
}

const LengthUnit* LengthUnit::getYard()
{
    static const LengthUnit yard(YARD_TO_BASEUNIT, "YARD");
    return &yard;
}

const LengthUnit* LengthUnit::getMile()
{
    static const LengthUnit mile(MILE_TO_BASEUNIT, "MILE");
    return &mile;
}

std::list<const Unit*> LengthUnit::getLengthUnitList()
{
    static std::list<const Unit*> lengthUnitList;
    if (lengthUnitList.empty())
    {
        lengthUnitList.push_back(MILE);
        lengthUnitList.push_back(YARD);
        lengthUnitList.push_back(FEET);
    }
    return lengthUnitList;
}

void LengthUnit::output(int amount, std::ostream& stream, const Unit* unit)
{
    Unit::formatOutput(amount, stream, unit, getLengthUnitList());
}
